package com.wx.javacode.poly_.object_;

/**
 * ClassName:Finalize_
 * Package :com.wx.javacode.poly_.object_
 * Description :
 *
 * @Author : coder_mu
 * @Create : 2023/5/25 - 21:15
 */
public class Finalize_ {
    public static void main(String[] args) {
        Car bmw = new Car("bmw");
        bmw = null;
        System.gc();
        System.out.println("程序结束");
    }
}

class Car{
    private String name;

    public Car(String name) {
        this.name = name;
    }

    @Override
    protected void finalize() throws Throwable {
        System.out.println("销毁了汽车 "+name);
        System.out.println("释放了一些资源");
    }
}